package com.yh.Dao.Impl;

import com.yh.Dao.IBordDao;
import com.yh.until.DBuntil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class BordDaoImpl extends DBuntil implements IBordDao {
    Connection conn=null;
    PreparedStatement pst=null;
    ResultSet rs=null;

    @Override
    public List keyWord(String tle) {
        List list=new ArrayList();
        conn=getConn();
        try {
            String sql="select * from bord where title like ?";
            pst=conn.prepareStatement(sql);
            pst.setString(1,tle+"%");
            rs=pst.executeQuery();
            while (rs.next()){
                String title=rs.getString("title");
                list.add(title);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            clossAll(conn,pst,rs);
        }

        return list;
    }
}
